﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager" runat="server" />
    <style type="text/css">
        body
        {
            font-family: Arial;
        }
    </style>
</head>
<body>
    <form id="form" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            function openWindow(sender, args) {
                var dataObject = new Object();
                dataObject.guid = newGuid();
                dataObject.someString = "Hello World!";
                dataObject.someMoney = 45.2;
                dataObject.title = sender.get_value() + " " + new Date();
                var oManager = GetRadWindowManager();
                var oWnd = oManager.open('ModalWindow.aspx?guid=' + dataObject.guid, dataObject.guid);
                oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close);
                oWnd.set_title(dataObject.title);
                oWnd.set_width(600);
                oWnd.set_height(200);
                oWnd.set_visibleStatusbar(false);
                oWnd.set_modal(true);
                oWnd.center();
                var containerObject = new Object();
                containerObject.data = dataObject;
                containerObject.callbackMethod = openWindowCallback;
                $("body").data(dataObject.guid, containerObject);
            }
            function openWindowCallback(dataReturn) {
                $("#result").html("Return value out of IFrame/Postback Window <span style='color:red;'>" + dataReturn.someMoney + "</span>");
                GetRadWindowManager().getWindowById(dataReturn.guid).close();
            }
            function doRandom() { return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); }
            function newGuid() { return (doRandom() + doRandom() + doRandom() + doRandom() + doRandom() + doRandom() + doRandom() + doRandom()); }
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager" runat="server">
        </telerik:RadAjaxManager>
        <telerik:RadWindowManager runat="server" ID="RadWindowManager"></telerik:RadWindowManager>
        <div>
            <telerik:RadButton runat="server" Text="Open Window" AutoPostBack="false" OnClientClicked="openWindow" Value="Modal IFrame">
            </telerik:RadButton>
            <div style="padding: 10px; font-size: 20px; font-weight: bold;" id="result"></div>
        </div>
    </form>
</body>
</html>
